Skip to content

[lab] Visual polish for RichTextEditor and toolbar - #4818

Open
ernestt wants to merge 1 commit into
mainfrom
codex/rich-text-editor-visuals
Open

[lab] Visual polish for RichTextEditor and toolbar#4818
ernestt wants to merge 1 commit into
mainfrom
codex/rich-text-editor-visuals

Conversation

@ernestt

@ernestt ernestt commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Refreshes the lab RichTextEditor so it looks and behaves like an Astryx form field, adds a compact formatting toolbar, and replaces the browser URL prompt with an Astryx link dialog.

This revision is intentionally scoped to @astryxdesign/lab: it does not modify Toolbar, ToggleButton, MoreMenu, OverflowList, useListFocus, or any other Core component.

The component remains named RichTextEditor: it is an extensible Lexical authoring surface with formatting, plugins, nodes, history, and serialization—not only a rich-text value input.

Field visuals and sizing

  • Matches TextArea/TextInput for the resting outline, hover treatment, focus-within ring, radius, disabled/read-only treatment, and semantic status colors.
  • Aligns placeholder and entered text by sharing the same body typography, line height, responsive coarse-pointer sizing, and content inset.
  • Adds minHeight: SizeValue for the editable surface. Numbers are pixels, strings are CSS lengths, the default remains 4.5rem, and content can grow beyond the minimum.
  • Adds a dedicated toolbar slot before the padded editing surface, keeping controls flush with the top edge and in the correct visual and keyboard order.
  • Corrects accessible-name wiring: the contenteditable has its own input ID and references a real label ID.

Status treatment

  • Adds the same in-field semantic status icon used by Astryx inputs.
  • Supports statusVariant="attached" | "detached" | "tooltip":
    • attached — the icon stays in the editor and the message connects below the field.
    • detached — the message sits below as its own status row with an icon.
    • tooltip — a focusable in-editor icon reveals the message without reserving a message row.
  • Error sets aria-invalid; descriptions, status messages/tooltips, character count, and keyboard hints remain correctly composed through aria-describedby.

Formatting toolbar

  • Uses the existing Astryx Toolbar with small controls; ToggleButton size is passed explicitly inside Labs, so no Core sizing behavior changes.
  • Groups Undo/Redo, block formatting, and inline formatting with vertical dividers.
  • Combines Paragraph, Heading 1–3, bulleted list, numbered list, and block quote into one block-format Selector.
  • Leaves the Selector's standard adaptive popover placement unchanged.
  • Uses ToggleButtons for Bold, Italic, Underline, Strikethrough, Inline code, and Link, with active state synchronized to the Lexical selection.
  • Removes the experimental AI action.

Narrow-width behavior

  • Keeps every action as a direct toolbar control; there is no More menu or OverflowList dependency.
  • Wraps the complete action row in a Labs-only, non-wrapping horizontal scroll container.
  • Preserves Toolbar's existing roving-arrow keyboard behavior; focusing an off-screen control scrolls it into view.
  • Adds resizable and 240–900 px stress-test stories.
  • Browser verification asserts overflow-x: auto and scrollWidth > clientWidth at 340 px.

Link workflow

  • Replaces window.prompt with an Astryx Dialog containing a URL TextInput and standard Cancel/Add/Update/Remove actions.
  • Uses the canonical Dialog header/content/footer layout, removing the doubled header inset and aligning all sections to one padding rhythm.
  • Supports the toolbar action and Cmd/Ctrl+K while preserving the Lexical selection.
  • Sanitizes URLs to http, https, mailto, or tel; unsafe schemes are rejected.
  • Keeps the existing promptForUrl extension point for consumers with a synchronous custom URL flow.
  • Preserves new-tab link attributes in Lexical node data so they serialize and round-trip.

Screenshots

These are GitHub-hosted PR attachments and are not committed to the repository.

Field focus, placeholder alignment, and minHeight

Focused RichTextEditor showing aligned placeholder text and custom minimum height

Status variants

Attached error Detached warning
Attached error with in-editor error icon Detached warning message with warning icon

Tooltip status opened from the in-editor error icon

Compact toolbar and block-format selector

Compact flush toolbar with dividers and the block-format selector open

Horizontal toolbar scroll

Narrow editor retaining every formatting action in a horizontally scrollable toolbar

Astryx link dialog

Insert link dialog with aligned header, content, and footer spacing

Validation

  • 86 focused RichTextEditor tests
  • ESLint on changed Labs and Storybook files
  • Lab documentation typecheck and package build
  • Storybook typecheck and production build
  • Browser assertion and screenshot pass for narrow-width scrolling and the link dialog
  • Repository sync, package-boundary, changeset, demo-media, executable-bit, and CLI-structure checks
  • PR accessibility and RTL audits

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
astryx Ignored Ignored Aug 8, 2026 5:18am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 8, 2026
@github-actions github-actions Bot added the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch 2 times, most recently from 0ab6c35 to c4ed993 Compare August 8, 2026 01:59
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

RichTextEditor (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1840 -
Complexity N/A Very High (126) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/lab N/A 3.7KB 1.6KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from c4ed993 to 8c6c04f Compare August 8, 2026 03:10
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch 2 times, most recently from f29b0f8 to c040a87 Compare August 8, 2026 04:14
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from c040a87 to 67b97b3 Compare August 8, 2026 04:21
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from 67b97b3 to ecd9766 Compare August 8, 2026 04:29
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from ecd9766 to a265733 Compare August 8, 2026 04:39
@ernestt
ernestt marked this pull request as ready for review August 8, 2026 04:40
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from a265733 to 92fd404 Compare August 8, 2026 04:57
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 8, 2026
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from 92fd404 to f12bf8c Compare August 8, 2026 05:08
@ernestt
ernestt force-pushed the codex/rich-text-editor-visuals branch from f12bf8c to dfe15ed Compare August 8, 2026 05:18
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
@ernestt ernestt changed the title Refresh RichTextEditor visuals and toolbar Visual polish for RichTextEditor and toolbar Aug 10, 2026
@ernestt
ernestt requested a review from potatowagon August 10, 2026 23:28
@ernestt ernestt changed the title Visual polish for RichTextEditor and toolbar [lab] Visual polish for RichTextEditor and toolbar Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant